package statement;

public class SwitchStatementDemo {
    public static void main(String[] args) {
        // 1. 基本switch用法
        int dayOfWeek = 3;
        switch (dayOfWeek) {
            case 1:
                System.out.println("星期一");
                break;
            case 2:
                System.out.println("星期二");
                break;
            case 3:
                System.out.println("星期三");
                break;
            case 4:
                System.out.println("星期四");
                break;
            case 5:
                System.out.println("星期五");
                break;
            case 6:
            case 7:
                System.out.println("周末");
                break;
            default:
                System.out.println("无效的星期");
        }

        // 2. switch使用字符串（Java 7+支持）
        String season = "夏天";
        switch (season) {
            case "春天":
                System.out.println("春暖花开");
                break;
            case "夏天":
                System.out.println("夏日炎炎");
                break;
            case "秋天":
                System.out.println("秋高气爽");
                break;
            case "冬天":
                System.out.println("冬雪纷飞");
                break;
            default:
                System.out.println("季节未知");
        }

        // 3. Java 12+的switch表达式（箭头语法）
        int month = 2;
        String quarter = switch (month) {
            case 1, 2, 3  -> "第一季度";
            case 4, 5, 6  -> "第二季度";
            case 7, 8, 9  -> "第三季度";
            case 10, 11, 12 -> "第四季度";
            default -> "无效月份";
        };
        System.out.println(month + "月属于" + quarter);
    }
}
